
# -*- coding:utf-8 -*-
import os
import ConfigParser
from pymongo import MongoClient

# pip install pymongo
# https://www.cnblogs.com/huey/p/4334152.html parseConfig使用

# 项目路径
rootDir = os.path.split(os.path.realpath(__file__))[0]
# config.ini文件路径
configFilePath = os.path.join(rootDir, 'config.txt')
 
 
cp = ConfigParser.RawConfigParser()
cp.read('config.txt')

uri = cp.get('datasource','url')
client = MongoClient(uri)
print client

db = client["eshop"]
user_coll = db["users"]

new_user = {"username": "nina", "password": "xxxx", "email":"123456@qq.com "}
result = user_coll.insert_one(new_user)
print result

